import {reqGetProvice } from "@/api/index";

const state = {
    cityList:{
        data: {
            hotCityList: [],
            cityList: [],
        }
    }
};

const getters = {
    hotCityList(state){
        // console.log(state.cityList.data.hotCityList);
        return state.cityList.data.hotCityList.map(item =>{
            return{
               cityName:item.name,
               code:item.code,
            }
        })
    },
    cityList(state){
        
        return state.cityList.data.cityList
    }
};

const actions = {
   async getCityList({commit}){
    const res = await reqGetProvice()
    commit('GETCITYLIST',res.data)
   }
};

const mutations = {
    GETCITYLIST(state,cityList){
        state.cityList = cityList
    }
};

export default {
  state,
  getters,
  actions,
  mutations,
};